Filter hook '{$action}_overrides'

in WP Core File wp-admin/includes/file.php at line 859

View Source

{$action}_overrides

Filter Hook
Description
Filters the override parameters for a file before it is uploaded to WordPress. The dynamic portion of the hook name, `$action`, refers to the post action. Possible hook names include: - `wp_handle_sideload_overrides` - `wp_handle_upload_overrides` }

Hook Information

File Location wp-admin/includes/file.php View on GitHub
Hook Type Filter
Line Number 859

Hook Parameters

Type Name Description
array|false $overrides An array of override parameters for this file. Boolean false if none are provided. See {@see _wp_handle_upload()}.
array $file { Reference to a single element from `$_FILES`.

Usage Examples

Basic Usage
<?php
// Hook into {$action}_overrides
add_filter('{$action}_overrides', 'my_custom_filter', 10, 2);

function my_custom_filter($overrides, $file) {
    // Your custom filtering logic here
    return $overrides;
}

Source Code Context

wp-admin/includes/file.php:859 - How this hook is used in WordPress core
<?php
 854  	 *     @type string $tmp_name The temporary filename of the file in which the uploaded file was stored on the server.
 855  	 *     @type int    $size     The size, in bytes, of the uploaded file.
 856  	 *     @type int    $error    The error code associated with this file upload.
 857  	 * }
 858  	 */
 859  	$overrides = apply_filters( "{$action}_overrides", $overrides, $file );
 860  
 861  	// You may define your own function and pass the name in $overrides['upload_error_handler'].
 862  	$upload_error_handler = 'wp_handle_upload_error';
 863  	if ( isset( $overrides['upload_error_handler'] ) ) {
 864  		$upload_error_handler = $overrides['upload_error_handler'];

PHP Documentation

<?php
/**
	 * Filters the override parameters for a file before it is uploaded to WordPress.
	 *
	 * The dynamic portion of the hook name, `$action`, refers to the post action.
	 *
	 * Possible hook names include:
	 *
	 *  - `wp_handle_sideload_overrides`
	 *  - `wp_handle_upload_overrides`
	 *
	 * @since 5.7.0
	 *
	 * @param array|false $overrides An array of override parameters for this file. Boolean false if none are
	 *                               provided. See {@see _wp_handle_upload()}.
	 * @param array       $file      {
	 *     Reference to a single element from `$_FILES`.
	 *
	 *     @type string $name     The original name of the file on the client machine.
	 *     @type string $type     The mime type of the file, if the browser provided this information.
	 *     @type string $tmp_name The temporary filename of the file in which the uploaded file was stored on the server.
	 *     @type int    $size     The size, in bytes, of the uploaded file.
	 *     @type int    $error    The error code associated with this file upload.
	 * }
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-admin/includes/file.php
Related Hooks

Related hooks will be displayed here in future updates.